package com.heima.article.config;

import com.heima.article.interceptor.ArticleInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class WebConfig extends WebMvcConfigurationSupport {
    @Autowired
    private ArticleInterceptor articleInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(articleInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/api/v1/article/save")
                .excludePathPatterns("/api/v1/article/findByPage")
                .excludePathPatterns("/api/v1/article/findById/{id}")
                .excludePathPatterns("/api/v1/article/delArticle")
                .excludePathPatterns("/api/v1/article/updArticle")
                .excludePathPatterns("/api/v1/author/save")
                .excludePathPatterns("/api/v1/author/getAuthorByUserId")
                .excludePathPatterns("/api/v1/article/find_news_comments");
    }
}
